const { tool,api,time } = getApp();
Page({
    // 一键登录
    login() {
        api.show();
        wx.getUserProfile({
            desc: '登录',
            success(e) {
                let { avatarUrl,nickName,gender } = e.userInfo;
                tool.getUserInfo().then(data => {
                    if (data) {
                        api.setStorage('loginTime',time.getStamp() + 24 * 3600000);
                        api.showToast('登录成功','success');
                        setTimeout(() => {
                            api.switchTab('/pages/class/list/index');    
                        }, 1500);
                    } else {
                        api.showModal('提示','您尚未注册，请注册后重试',false).then(res => {
                            if (res) api.navigateTo(`/pages/user/register/index?nickname=${nickName}&avatar=${avatarUrl}&gender=${gender ? 0 : 1}`);
                        });
                    }
                })
            },
        })
    },

})